home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE23
/
EX2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-19
|
2KB
|
59 lines
#include <genstub.c>
LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static UINT uMessageID;
static ATOM aDataTransmitted;
switch (uMsg) // Process windows messages.
{
case WM_CREATE:
// Register a message for private protocol exchange between application instances.
uMessageID = RegisterWindowMessage( "generic" );
// Create atom containing data to exchange.
aDataTransmitted = GlobalAddAtom( "Transmitted Data" );
break ;
case WM_COMMAND: // Process menu items.
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
// Send the private message to every applicationÆs main window.
PostMessage((HWND) -1, uMessageID, aDataTransmitted, 0L );
break;
case IDM_EXIT:
DestroyWindow (hWnd);
break;
}
break;
case WM_DESTROY:
GlobalDeleteAtom( aDataTransmitted );
PostQuitMessage( 0 );
break;
default:
if (uMsg == uMessageID) /* Check if the message is the registered message. */
{
char cBuf[128]; // Buffer for text output.
char cAtomContent[32]; // Buffer for storing atom name in local data.
HDC hDC = GetDC( hWnd );
GlobalGetAtomName( wParam, cAtomContent, 32 );
TextOut( hDC, 0, 0, cBuf, wsprintf( cBuf, "Received %s", (LPSTR) cAtomContent ) );
ReleaseDC( hWnd, hDC );
}
else
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
return (0L);
}
#include <about.c>